package org.phalanx.client.dialogs.servernode;

import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.JPanel;
import javax.swing.JTextField;

import org.phalanx.client.UI.FontFactory;
import org.phalanx.client.UI.PhalanxIconButton;
import org.phalanx.client.UI.swing.PhalanxButtonFactory;

public class ServerNodeConnectionFieldPanel extends JPanel {
	private ServerNodeConnectionPanel masterPanel;
	private JTextField connectionNodeField;
	private PhalanxIconButton okButton;
	
	public ServerNodeConnectionFieldPanel(ServerNodeConnectionPanel parentPanel){
		this.masterPanel = parentPanel;
		initializePanel();
		setUpComponents();
		addComponents();
	}
	
	private void initializePanel(){
		this.setBackground(Color.black);
		this.setLayout(new FlowLayout(FlowLayout.LEFT));
	}
	
	private void setUpComponents(){
		connectionNodeField = new JTextField();
		connectionNodeField.setColumns(25);
		connectionNodeField.setFont(FontFactory.getInstance().getTextFieldFont());
		
		okButton = PhalanxButtonFactory.getButton(PhalanxButtonFactory.DEFAULT_OK_BUTTON);
		okButton.setForeground(Color.white);
		okButton.setText("Connect");
		okButton.setName("connectnode");
		
		okButton.addButtonListener(masterPanel);
	}
	
	private void addComponents(){
		this.add(connectionNodeField);
		this.add(okButton);
	}
	
	public JTextField getTextField(){
		return connectionNodeField;
	}
}
